package com.cictec.middleware.tde.rm.protocol;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TerminalProtocolCodecFactory implements ProtocolCodecFactory {

//	@Autowired
//	final private TerminalProtocolDecoder decoder;
//	@Autowired
//	final private TerminalProtocolEncoder encoder;
	@Autowired
	private TerminalProtocolDecoder decoder;
	@Autowired
	private TerminalProtocolEncoder encoder;

	public TerminalProtocolCodecFactory() {
	}

	public TerminalProtocolCodecFactory(TerminalProtocolDecoder decoder, TerminalProtocolEncoder encoder) {
		this.decoder = decoder;
		this.encoder = encoder;
	}

	@Override
	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		return encoder;
	}

	@Override
	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		return decoder;
	}

}
